package com.bob.clan.wxconnector.interceptor;


import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Slf4j
public class SecurityInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        // 获取当前登录用户信息
//        SysUser user = (SysUser) request.getSession().getAttribute("session_user");
//        if (user == null) {
//            user = new SysUser();
//            user.setAccount("temp");
//            user.setId(0);
//            user.setName("临时用户");
//            request.getSession().setAttribute("session_user",user);

            // 当前用户没有登录系统，返回错误信息，让用户回到登录页面
//            log.error(request.getRequestURI()+",用户没有登录系统。");
//            request.setAttribute("errMsg", "请先登录系统！");
//            request.getRequestDispatcher("/").forward(request, response);


//              response.sendRedirect("/?errMsg=请先登录系统！");
//              response.sendRedirect("/logInController/login");
        if(true){
            return true;
        } else {
            return true;
        }

    }
}
